<?php
namespace app\modules\adminapi\controllers;

use app\models\Category;
use app\libs\Util;

class ListcatController extends \app\modules\adminapi\ForceLoginPure {

    public function run() {
        $model = new Category();
        $ret = $model->getListByCondition('id,pid,name', '1=1');

        if(null !== $ret) {
            $ret = Util::listToTree($ret);
        }

        $this->ajaxReturn([
            'data' => $ret
        ]);
    }

}
